package games.menem 
{
	import org.flixel.FlxSprite;
	import org.flixel.FlxG;
	
	/**
	 * ...
	 * @author Jacowaco
	 */
	public class MenemChar extends FlxSprite 
	{
		[Embed(source = "../../../assets/charly/CH1_A.png")] private var img:Class;
		
		private var velX:Number;
		private var velY:Number;
		
		public function MenemChar(_x:Number=0, _y:Number=0) 
		{
			super(_x, _y, img);
			
			health = 4;
			
			velX = 400;
			velY = 200;
			
			velocity.x = velX;
			
			centerOffsets();
		}
		
		override public function update():void 
		{
			if (FlxG.keys.UP)
			{
				velocity.y = -velY;
			}
			else if (FlxG.keys.DOWN)
			{
				velocity.y = velY;
			}
			else
			{
				velocity.y = 0;
			}
			
			if(y > FlxG.height - height)
				y = FlxG.height - height;
			if(y < 0)
				y = 0;
				
			if(FlxG.keys.justPressed("SPACE"))
			{
				if ((FlxG.state as MenemGame).bullets.countLiving() < (FlxG.state as MenemGame).bullets.length)
				{
				var bullet:FlxSprite = (FlxG.state as MenemGame).bullets.recycle() as FlxSprite;
				bullet.reset(x + (width - bullet.width)/2, y + (height - bullet.height)/2);
				bullet.velocity.x += velocity.x * 1.8;
				//bullet.velocity.y += velocity.y;
				}
			}
		}
		
	}

}